#pragma once
#include "WareTypes.h"
#include "WarePrepare.h"

namespace Ware
{
	class ISceneManager;
	class IResourceManager;
}

class CGameScene;

using namespace Ware;

class CGameSceneManager
{
private:
	CGameSceneManager() : m_uActiveSceneID(0), m_uSceneIDSeed(0), m_pResourceManager(NULL), m_pSceneManager(NULL) {}
	~CGameSceneManager() {}
public:
	static CGameSceneManager& Instance()
	{
		static CGameSceneManager _inst;
		return _inst;
	}
	
	typedef map< uint32, CGameScene* > GameSceneMap;

	void		Init( ISceneManager* pSceneManager, IResourceManager* pResourceManager );	
	
	uint32		CreateSceneISO( int32 nMapWidth, int32 nMapHeight, int32 nGridWidth, int32 nGridHeight, const VCHAR* szTextureName, int32 nPriority = 0, int32 nRecycleLevel = 0xffffffff );
	uint32		CreateSceneTile( int32 nMapWidth, int32 nMapHeight, int32 nGridWidth, int32 nGridHeight, const VCHAR* szTextureName, int32 nPriority = 0, int32 nRecycleLevel = 0xffffffff );
	uint32		CreateScene( const VCHAR* szTerrainCfgFileName, int32 nPriority = 0, int32 nRecycleLevel = 0xffffffff );

	CGameScene*	GetScene( uint32 uSceneID );
	void		SetActiveScene( uint32 uSceneID )	{ m_uActiveSceneID = uSceneID; }
	CGameScene* GetActiveScene()					{ return GetScene( m_uActiveSceneID ); }

	void		ReleaseScene( uint32 uSceneID );

private:

	uint32		AddGameScene( CGameScene* pScene );

private:

	uint32				m_uActiveSceneID;

	uint32				m_uSceneIDSeed;

	GameSceneMap		m_mapGameScene;

	ISceneManager*		m_pSceneManager;
	IResourceManager*	m_pResourceManager;
};